import { scene } from './utils/init'
import * as THREE from 'three'
import { guiChangeColor } from './utils/gui'

function initBase() {
  const geometry = new THREE.SphereGeometry(1, 32, 16)

  const textureLoader = new THREE.TextureLoader()
  const texture = textureLoader.load('texture/one/basecolor.jpg')
  texture.colorSpace = THREE.SRGBColorSpace
  const transTextureLoader = new THREE.TextureLoader()
  const transTexture = transTextureLoader.load('texture/one/opacity.jpg')

  // 引入环境遮挡贴图
  const aoTextureLoader = new THREE.TextureLoader()
  const aoTexture = aoTextureLoader.load('texture/one/ambientOcclusion.jpg')

  const material = new THREE.MeshBasicMaterial({ 
    map: texture,
    // alphaMap: transTexture,
    // transparent: true,
    aoMap: aoTexture // 属性配置
  })

  const mesh = new THREE.Mesh(geometry, material)
  console.log(mesh, 'mesh');
  mesh.geometry.setAttribute('uv2', new THREE.Float32BufferAttribute(mesh.geometry.attributes.uv.array, 2))
//   guiChangeColor(texture)
  scene.add(mesh)
}

initBase()